#!/bin/sh
currentDir=$(cd "$(dirname "$0")"; pwd)
cd ${currentDir}

PWD=${currentDir}
dname=$(dirname "$PWD")

device_id=$1
if  [ x"${device_id}" = x ] ;
then
    echo "turing train fail" >> ${currentDir}/result/8p/train_${device_id}.log
    exit
else
    export DEVICE_ID=${device_id}
fi

DEVICE_INDEX=$(( DEVICE_ID + RANK_INDEX * 8 ))
export DEVICE_INDEX=${DEVICE_INDEX}

#mkdir exec path
mkdir -p ${currentDir}/result/8p/${device_id}
rm -rf ${currentDir}/result/8p/${device_id}/*
cd ${currentDir}/result/8p/${device_id}

#start exec
DATA_DIR=/home/imagenet_TF
python3 ${dname}/imagenet_main.py --resnet_size=50 --resnet_version=1 --epochs_between_evals=90 --hooks=ExamplesPerSecondHook --batch_size=128 --data_dir=${DATA_DIR} --model_dir=./model_dir > ${currentDir}/result/8p/train_${device_id}.log 2>&1

if [ $? -eq 0 ] ;
then
    echo "turing train success" >> ${currentDir}/result/8p/train_${device_id}.log
else
    echo "turing train fail" >> ${currentDir}/result/8p/train_${device_id}.log
fi

